<?php

namespace app\model\pms;

use think\Model;

/**
 * t_goods_spec_tpl 商品规格模板表
 * @property integer $id 商品规格id(主键)
 * @property string $name 规则名
 * @property string $value 规则值
 */
class GoodsSpecTpl extends Model
{
    /**
     * The connection name for the model.
     *
     * @var string|null
     */
    protected $connection = 'mysql';
    
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 't_goods_spec_tpl';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $pk = 'id';

    public function setValueAttr($value)
    {
        $value = json_encode($value, JSON_UNESCAPED_UNICODE);
        return $value;
    }

    public function getValueAttr($value)
    {
        return json_decode($value ?? "{}", true) ?? [];

    }
}
